Skip to content

BUG GH#40498 Fillna other missing values not modified #42981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed

BUG GH#40498 Fillna other missing values not modified #42981

wants to merge 15 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 11, 2021

@ghost
Copy link
Author

ghost commented Aug 11, 2021

Should be noted that these tests will not fail, even without my changes, because of an open issue - #18463.

@ghost ghost changed the title Fillna other missing values not modified BUG GH#40498 Fillna other missing values not modified Aug 11, 2021
@mzeitlin11 mzeitlin11 added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Aug 14, 2021
@pep8speaks
Copy link

pep8speaks commented Sep 6, 2021

Hello @mikephung122! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-09-30 05:15:10 UTC

modification_index
]
else:
value = value_map.reindex(self.index, copy=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't you just set copy=True for object type?

Copy link
Author

@ghost ghost Sep 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the original logic that was present for all value dictionaries before I added the separate object type conditional.

I'm not sure why they chose to explicitly set copy=False since in both the old and new code we're replacing value with the reindexed version and the original value is not used anywhere else. In addition, unless every index is a key in the value dictionary I believe this will have no effect because - "A new object is produced unless the new index is equivalent to the current one and copy=False".

Will remove the unnecessary argument and return to the default since there's no clear value for it.

modification_index
]
else:
value = value_map.reindex(self.index)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you don't add the copy does this just work e.g. do you still need L6314-6325

Copy link
Author

@ghost ghost Sep 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the testing method we're using cannot differentiate the following:

result = pd.Series([1, None, 3, "four"])
expected = pd.Series([1, np.nan, 3, "four"])
tm.assert_equal(result, expected)

If you remove L6314-6325 the unit tests will pass but the original problem will still exist. I mentioned this on my initial Pull Request but these tests will not fail because of an open issue - #18463. I probably should've clarified if it's worth writing tests with other bugs in mind, or to write them as if the bug will be fixed eventually.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.reindex should just work here. I am really not sure what you are trying to do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback Sorry I might not be following, what did you want me to update here?

@ghost ghost requested a review from jreback September 28, 2021 00:47
@jreback jreback modified the milestone: 1.4 Sep 28, 2021
@ghost ghost closed this Oct 26, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Series.fillna is altering None values of unspecified columns
3 participants